package com.eddy.liveline.requirement.service;

import com.eddy.liveline.core.spring.mybatis.pagehelper.Table;
import com.eddy.liveline.requirement.dao.RequirementMapper;
import com.eddy.liveline.requirement.pojo.Requirement;
import com.eddy.liveline.requirement.pojo.RequirementTableQuery;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by eddy on 2019/6/23.
 */

@Service
@Transactional
public class RequirementServiceImpl implements RequirementService {

    @Resource
    private RequirementMapper requirementMapper;


    @Override
    public boolean batchSave(List<Requirement> requirements) {
        return requirementMapper.batchSave(requirements);
    }

    @Override
    public boolean deleteById(String id) {
        return requirementMapper.deleteById(id);
    }

    @Override
    public boolean deleteByIds(List<String> ids) {
        return requirementMapper.deleteByIds(ids);
    }

    @Override
    public Requirement getById(String id) {
        return requirementMapper.getById(id);
    }

    @Override
    public Table<Requirement> query(RequirementTableQuery query) {
        Page<Object> page = PageHelper.startPage(query.getPageNumber(), query.getPageSize(), true);
        List<Requirement> list = requirementMapper.query(query);
        return new Table<Requirement>(page.getTotal(), list);
    }

    @Override
    public boolean batchUpdate(List<Requirement> requirements) {
        return requirementMapper.batchUpdate(requirements);
    }
}
